<?php
include_once(dirname(__FILE__)."/../inc/common.php"); 

$flowClass = new tally_flow();
$accountClass = new tally_account();
// 上月收支
$startTime = strtotime(date("Y-m")." -1 month");
$endTime = strtotime(date("Y-m"));
$lastMonthIn = $flowClass->getCountByTimeRange($userId, 
	tally_flow::$INOUT_INCOMME, $startTime, $endTime);
$lastMonthOut = $flowClass->getCountByTimeRange($userId, 
	tally_flow::$INOUT_EXPENSE, $startTime, $endTime);
$lastMonthNetIncome = $lastMonthIn-abs($lastMonthOut);
// 本月收支
$startTime = strtotime(date("Y-m"));
$endTime = time();
$thisMonthIn = $flowClass->getCountByTimeRange($userId, 
	tally_flow::$INOUT_INCOMME, $startTime, $endTime);
$thisMonthOut = $flowClass->getCountByTimeRange($userId, 
	tally_flow::$INOUT_EXPENSE, $startTime, $endTime);
$thisMonthNetIncome = $thisMonthIn-abs($thisMonthOut);
// 净资产
$asset = $accountClass->getAsset($userId);
$owed = $accountClass->getOwed($userId);
$netAsset = $asset+$owed;
?>
	 <!--begin:数据列表-------------------------------------------------------------------------------------------------->
		     
      	<!-- begin:导航条 -->
		<div class="titlebar">
		   <h3>记账</h3>
		</div>
		<!-- end:导航条 -->

		<div class="clear"></div>
		
		<div class="home_report">
			<table class="listtable">
				<thead>
					<tr>
						<th width="33%" colspan="2">上月收支统计</th>
						<th width="33%" colspan="2">本月收支统计</th>
						<th width="33%" colspan="2">财务状况</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td width="5%">收入</td>						
						<td class="number"><?php echo number_format($lastMonthIn,2,".",""); ?></td>
						<td width="5%">收入</td>
						<td class="number"><?php echo number_format($thisMonthIn,2,".",""); ?></td>
						<td width="5%">资产</td>
						<td class="number"><?php echo number_format($asset,2,".",""); ?></td>
					</tr>
					<tr>
						<td>支出</td>						
						<td class="number"><?php echo number_format($lastMonthOut,2,".",""); ?></td>
						<td>支出</td>
						<td class="number"><?php echo number_format($thisMonthOut,2,".",""); ?></td>
						<td>负债</td>
						<td class="number"><?php echo number_format($owed,2,".",""); ?></td>
						
					</tr>
					<tr>
						<td>净收入</td>						
						<td class="number"><?php echo number_format($lastMonthNetIncome,2,".",""); ?></td>
						<td>净收入</td>
						<td class="number"><?php echo number_format($thisMonthNetIncome,2,".",""); ?></td>
						<td>净资产</td>
						<td class="number"><?php echo number_format($netAsset,2,".",""); ?></td>
					</tr>
				</tbody>
				<tfoot>
					<tr><td colspan="6" style="text-align: left;padding-left: 5px;">统计结果以人民币计 <a href="/report/index.php">更多统计»</a></td></tr>
				</tfoot>
			</table>
		</div>
		

	<table style="width: 100%;">
		<tr>
	   		<td>
				<div class="box main_chart">
					<div id="month_chart" style="width: 100%;height:380px;margin: 0px auto;text-align: center;">

	    			</div>
				</div>
			</td>
		</tr>
	</table>

	
 <!--end:数据列表区-------------------------------------------------------------------------------------------------->	